const router = require("express").Router();
const { body } = require("express-validator");
const validate = require("../middleware/validate");
const { auth } = require("../middleware/auth");
const ctrl = require("../controllers/user.controller");

// 获取当前用户
router.get("/me", auth(true), ctrl.getMe);

// 更新当前用户
router.patch(
    "/me",
    auth(true),
    [
        body("username").optional().isLength({ min: 2, max: 32 }),
        body("bio").optional().isString(),
        body("avatarUrl").optional().isString(),
    ],
    validate,
    ctrl.updateMe
);

module.exports = router;
